//
//  HTTeacher.swift
//  swift-practice
//
//  Created by yzt on 2022/11/1.
//

import Foundation

class HTTeacher {
    var completionHandler : ((Int)->Void)?
    
    let serialQueue = DispatchQueue(label: "networkRequests")
    
    func makeIncrementer (amount : Int, handler : @escaping (Int) -> Void){
        var runningTotal = 0
        runningTotal += amount
        self.completionHandler = handler
        
        DispatchQueue.global().asyncAfter(deadline: .now()+0.1){
            print("逃逸闭包延迟执行")
            handler(runningTotal)
        }
        print("函数执行结束")
    }
    
    func doSomeThing(){
        self.makeIncrementer(amount: 10) {
            print($0)
        }
    }
    
    deinit {
        print("HTTeacger deinit")
    }
    
}
